package com.xm.adv.viewholder;

import android.app.Activity;
import android.view.ViewGroup;
import android.widget.RelativeLayout;
import android.widget.VideoView;

import androidx.annotation.LayoutRes;

import com.xm.adv.Ctr.DrawCtr;
import com.xm.adv.R;

import java.util.List;

import xinya.com.baselibrary.bean.program.SceneBean;
import xinya.com.baselibrary.easyrecyclerview.adapter.BaseViewHolder;
import xinya.com.db.DaoMaster;


/**
 * Created by Administrator on 2017/3/28 0028.
 */
public class AdvViewHolder extends BaseViewHolder<SceneBean> {

    private final RelativeLayout viewDraw;
    private List<VideoView> videoViewList;

    public  interface  onGetDataListener{
        DaoMaster getDaoMaster();
        Activity getActivity();
    }

    onGetDataListener onGetDataListener;

    public void setOnGetDataListener(AdvViewHolder.onGetDataListener onGetDataListener) {
        this.onGetDataListener = onGetDataListener;
    }

    public AdvViewHolder(ViewGroup parent, @LayoutRes int res) {
        super(parent, res);
        viewDraw = $(R.id.viewDraw);
    }

    @Override
    public void setData(SceneBean data) {
        super.setData(data);
        videoViewList = DrawCtr.draw(onGetDataListener.getActivity(), viewDraw, data,1,0);
        for (int i = 0; i < videoViewList.size(); i++) {
            videoViewList.get(i).start();
        }
//        if (videoViewList==null){
//        }else {
//            LogUtil.LogShitou("AdvViewHolder--setData", "111111111111  "+videoViewList.size());
//
//        }
    }
    
}
